package com.home.auto_navigation.ui.pages;

import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import com.home.auto_navigation.common.AutoNavigationFileDecorator;
import com.home.auto_navigation.common.api.NavigationLink;
import com.home.auto_navigation.ui.AbstractPageObject;
import com.home.auto_navigation.ui.controllers.Button;

public class HomeAfterLoginPage extends AbstractPageObject {
	@FindBy(id = "hp01v0")
	private WebElement uniqueElement;
	@FindBy(linkText = "Sign Out")
	private WebElement singOut;
	@NavigationLink(successor = DownloadsPage.class)
	@FindBy(xpath = "//a/h3[text()='Downloads']")
	private Button downloads;
	
	public HomeAfterLoginPage() {
		PageFactory.initElements(new AutoNavigationFileDecorator(getDriver()), this);
		this.successors = new HashMap<Class<? extends AbstractPageObject>, Button>();
		this.successors.put(DownloadsPage.class, downloads);
	}
	
	@Override
	public boolean isExist() {
		try{
			if(uniqueElement.isDisplayed() && singOut.isDisplayed()){
				return true;
			}else return false;
		}catch(NoSuchElementException e){
		    return false;
		}
	}

	@Override
	public void invokeSuccessor(Map<String, String> businessData,
			Class<? extends AbstractPageObject> page) {
		// TODO Auto-generated method stub

	}

}
